flip.df <- read.table('heads-switches.csv', sep=',', header=T)

## look at help for read.table
?read.table

## show column names
colnames(flip.df)

## Summarize
summary(flip.df)

## Show structure
str(flip.df)

## Show beginning and head
head(flip.df)
tail(flip.df)

## R has *lots* of packages
## Load the lattice package into memory
## and plot
library(lattice)
plot1 <- histogram(  ~ A|Var, flip.df)
plot(plot1)

## Install and load the reshape2 package
## Packages only need to be installed once per computer
## but need to be loaded each R session
#install.packages('reshape2')
library(reshape2)

flip.melt <- melt(flip.df, id.vars=c('Var', 'Roll'))
head(flip.melt)
flip.cast <- dcast(flip.melt, ...~Var)
head(flip.cast)

## Plot
plot2 <- xyplot(jitter(Switch) ~ jitter(Heads), flip.cast )
plot(plot2)

